const { sqlConnect } = require('../../plugin/db');
const db = require('../../plugin/db');
const utils = require('../../plugin/utils');
const note = {
    /**添加修改笔记分类 */
    AddnoteClassify (req, res) {
        const data = req.body;
        const noteName = data.noteName;
        const edit_id = data.edit_id;
        let sql = ''
        if (!noteName) {
            utils.error(res, "分类名称不能为空");
            return;
        }
        if (edit_id != '') {
            //修改
            sql = `UPDATE note_classify SET name = ? WHERE Id = ${edit_id}`;
        } else {
            //添加
            sql = 'INSERT INTO note_classify (name) VALUES (?)';
        }
        const sqlArr = ["456789789"]
        const callBack = (err, result) => {
            if (err) {
                utils.error(res, "添加失败");
                return
            }
            utils.success(res, "添加分类成功");
        }
        db.sqlConnect(sql, sqlArr, callBack);

    }
}
module.exports = note